<template>
  <div class="table">
    <el-table
      :data="tableData"
      :loading="loading"
      style="width: 100%"
      :header-cell-style="{
        background: '#F1F1F1',
        'font-size': '14px',
        'font-weight': 600,
        color: '#333333',
      }"
      :cell-style="{
        'font-size': '14px',
        'font-weight': 400,
        color: '#333333',
      }"
    >
      <el-table-column label="序号" min-width="60" fixed="left">
        <template #default="scope">
          {{ (scope.$index + 1).toString().padStart(2, "0") }}
        </template>
      </el-table-column>
      <el-table-column prop="name" label="物业名称" min-width="140" />
      <el-table-column prop="address" label="详细地址" min-width="340" />
      <el-table-column label="运营模式" min-width="80">
        <template #default="scope">
          {{
            scope.row.operationMode == 1
              ? "自营"
              : scope.row.operationMode == 2
              ? "代管"
              : "-"
          }}
        </template>
      </el-table-column>
      <el-table-column prop="contacts" label="联系人" min-width="80" />
      <el-table-column prop="phone" label="联系方式" min-width="140" />
      <el-table-column label="操作" width="120" fixed="right">
        <template #default="scope">
          <el-button
            @click="detailData(scope.row)"
            type="primary"
            size="small"
            link
            style="color: #007aff; font-size: 14px"
            >详情</el-button
          >
          <el-button
            @click="editData(scope.row)"
            type="primary"
            size="small"
            link
            style="color: #007aff; font-size: 14px"
            >编辑</el-button
          >
        </template>
      </el-table-column>
      <template #empty>
        <el-empty :image="imgNone" />
      </template>
    </el-table>
  </div>
</template>

<script setup>
import { ElMessageBox } from "element-plus";
import { reactive, ref, defineProps } from "vue";
const imgNone = new URL("@/assets/image/imgNone.png", import.meta.url).href;
const emits = defineEmits(["table"]);

const props = defineProps({
  tableData: {
    type: Object,
    default: () => {},
  },
  loading: {
    type: Boolean,
    default: false,
  },
});

// 详情按钮
const detailData = (row) => {
  row.operation = "detail";
  emits("table", row);
};

// 编辑按钮
const editData = (row) => {
  row.operation = "edit";
  emits("table", row);
};
</script>

<style lang="less" scoped>
.table {
  margin-bottom: 15px;
}
</style>
